package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.CrrMaterialSummaryReportService;
import com.yunhai.model.entity.crr.CrrMaterialSummaryReportEntity;
import com.yunhai.model.vo.crr.CrrMaterialSummaryReportQuery;
import com.yunhai.model.vo.crr.CrrMaterialSummaryReportVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/crrMaterialSummaryReport")
public class CrrMaterialSummaryReportController {

	@Resource
	private CrrMaterialSummaryReportService crrMaterialSummaryReportService;


	/**
	 * 获取 CrrMaterialSummaryReport 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getCrrMaterialSummaryReportPagination(PaginationVo paginationVo, CrrMaterialSummaryReportQuery crrMaterialSummaryReportQuery ) throws Exception {
		IPage page = crrMaterialSummaryReportService.getCrrMaterialSummaryReportPagination(paginationVo, crrMaterialSummaryReportQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 CrrMaterialSummaryReport 所有数据
	 */
	@GetMapping("/allList")
	public Ret getCrrMaterialSummaryReportAllList( CrrMaterialSummaryReportQuery crrMaterialSummaryReportQuery ) throws Exception {
		List<CrrMaterialSummaryReportEntity> list = crrMaterialSummaryReportService.getCrrMaterialSummaryReportAllList( crrMaterialSummaryReportQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 CrrMaterialSummaryReport 详情
	 */
	@GetMapping("/{id}")
	public Ret getCrrMaterialSummaryReportDetailById(@PathVariable Long id) throws Exception {

	    CrrMaterialSummaryReportEntity crrMaterialSummaryReportEntity = crrMaterialSummaryReportService.getCrrMaterialSummaryReportDetail(id);
		return Ret.ok(crrMaterialSummaryReportEntity);
	}


	/**
	 * 新增 CrrMaterialSummaryReport
	 * */
	@PostMapping("")
	public Ret addCrrMaterialSummaryReport(@RequestBody CrrMaterialSummaryReportVo crrMaterialSummaryReportVo) throws Exception {

		crrMaterialSummaryReportService.addCrrMaterialSummaryReport(crrMaterialSummaryReportVo);
		return Ret.ok();
	}


	/**
	 * 更新 CrrMaterialSummaryReport
	 * */
	@PutMapping("")
	public Ret updateCrrMaterialSummaryReport(@RequestBody CrrMaterialSummaryReportVo crrMaterialSummaryReportVo) throws Exception {

		crrMaterialSummaryReportService.updateCrrMaterialSummaryReport(crrMaterialSummaryReportVo);
		return Ret.ok();
	}


	/**
	 * 删除 CrrMaterialSummaryReport
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveCrrMaterialSummaryReport( @RequestBody List<Long> ids ) throws Exception {

	    crrMaterialSummaryReportService.batchRemoveCrrMaterialSummaryReport(ids);
		return Ret.ok();
	}
}
